#include <iostream>
#include "Rules.h"

using namespace std;

Rules::Rules() {}

Rules::Rules(string s) {
	ListRule.push_back(s);	
}


Rules::~Rules(){}

string Rules::GetParamR(string s){
	SearchParam(s);
	if (it == ListParams.end()) {return *it;}
	else {return NULL;}
}

void Rules::addRule(string s){
	ListRule.push_back(s);
}

string Rules::NextParamR(){
	it++;
	return *it;
}

void Rules::CekParamR(){
	for(it = ListParams.begin();it != ListParams.end(); it++)
		{
		cout << "Paramsss = " << *it << "  ##  Nama : "<< name << endl;
		} 
}

void Rules::CekRule(){
	for(list<string>::iterator ite = ListRule.begin();ite != ListRule.end(); ite++)
		{
		cout << "Rule = " << *ite <<  endl;
		} 
}

void Rules::Add(string s){
	ListRule.push_back(s);	
}

string Rules::GetFirstElmt(){
return ListRule.front();
}

void Rules::addParam(string s){
	ListParams.push_back(s);
}

string Rules::GetLastElmt(){
return ListRule.back();
}

string Rules::GetElmt(string s){
	SearchElmt(s);
	if(it != ListRule.end()) {return *it;}
	else {return NULL;}
}

bool Rules::SearchElmt(string s){
	it = ListRule.begin();
	while (s.compare(*it) != 0 && it != ListRule.end()) {it++;}
	if (it == ListRule.end()) {return false;}
	return true;
}

bool Rules::SearchParam(string s){
	it = ListParams.begin();
	while (s.compare(*it) != 0 && it != ListRule.end()) {it++;}
	if (it == ListParams.end()) {return false;}
	return true;
}

string Rules::NextElmt()
{
	it++;
	return(*it);
}
